#ifndef CAMERACONTROL
#define CAMERACONTROL

#include "globals.h"

class Camera
{
public:
	Camera( );
	Camera(double ex, double ey, double ez, double zmin, double zmax, double fovx = 60.0);
	~Camera();
	void SetWindowID( int id ) { windowID = id; }
	int GetWindowID( int id ) { return windowID; }
	void GetEyeLocs( double* ex, double* ey, double* ez );
	void GetEyeDirs( double* dx, double* ey, double* ez );
	void RotateLocal( double x, double y, double z, double theta );
	void Detach() { bIsAttached = false; }
	void Initialize( double ex, double ey, double ez, double zmin, double zmax, double fovx = 60.0 );
	void Initialize( double ex, double ey, double ez, 
		             double xat, double yat, double zat,
					 double zmin, double zmax, double fovx = 40.0 );
	void ResetPosition( );
	void TranslateBy( double dx, double dy, double dz );
	void TranslateTo( double x, double y, double z );
	void PointAt( double x, double y, double z );
	void ResizeCallbackHandler( int w = -1, int h = -1 );
	void UpdateAttachedCamera();
	void GetWH( int* w, int* h );
	void ModelView();
	void SetViewSize(int w, int h) { iWindowW = w; iWindowH = h; }
	
private:
	bool bIsAttached;
	int iWindowW;
	int iWindowH;
	int windowID;
	double fovdeg;
	double eyex, eyey, eyez; //eye location
	double atx, aty, atz; // pointing eye towards
	double initx, inity, initz; // where we started, if we need to reset
	double refupx, refupy, refupz; // reference "up" direction for gluLookAt
	double znear;
	double zfar;

};

#endif